package com.ecp.commons.file;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

public class HintTag extends TagSupport {

	private static final long	serialVersionUID	= 1L;
	public static final String	ATTRNAME_INFO		= "info";
	public static final String	ATTRNAME_RETURNURL	= "returnUrl";
	public static final String	FORWARD_PAGE		= "/OurHome/modules/hint/msg.jsp";

	private Object				info;
	private String				returnUrl;
	private String				forwardPage;

	public HintTag() {
	}

	public int doStartTag() throws JspException {
		HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
		request.setAttribute(ATTRNAME_INFO, this.getInfo());
		request.setAttribute(ATTRNAME_RETURNURL, this.getReturnUrl());
		try {
			pageContext.forward(this.getForwardPage() == null ? FORWARD_PAGE : this.getForwardPage());
		} catch (IOException ex) {
			throw new JspException(ex);
		} catch (ServletException ex) {
			throw new JspException(ex);
		}

		return SKIP_BODY;
	}

	public void setInfo(Object info) {
		this.info = info;
	}

	public void setReturnUrl(String returnUrl) {
		this.returnUrl = returnUrl;
	}

	public void setForwardPage(String forwardPage) {
		this.forwardPage = forwardPage;
	}

	public Object getInfo() {
		return info;
	}

	public String getReturnUrl() {
		return returnUrl;
	}

	public String getForwardPage() {
		return forwardPage;
	}
}
